#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
int min(int a, int b)
{
    return a > b ? b : a;
}
class Solution {
public:
    int minOperations(vector<int>& nums, int x)
    {
        int target = 0, minlen = INT_MAX;
        for (auto n : nums) target += n; target -= x;
        if (target < 0) return -1;
        for (int left = 0, right = 0, sum = 0; right < nums.size(); right++)
        {
            sum += nums[right];
            while (sum > target)
            {
                sum -= nums[left++];
            }
            if (sum == target) minlen = min(minlen, (nums.size() - (right - left + 1)));
        }
        return minlen == INT_MAX ? - 1 : minlen;
    }
};

int main()
{
    
    return 0;
}